Open
Conversation
epsniff
reviewed
May 16, 2025
| } | ||
|
|
||
| // RandomSalt generates a random ten-digit number as a string | ||
| // |
Contributor
There was a problem hiding this comment.
You need to register your function as well here:
qlbridge/expr/builtins/builtins.go
Line 127 in 85f4541
something like:
expr.FuncAdd("random.salt", &RandomSalt{})
epsniff
reviewed
May 16, 2025
| } | ||
| func randomSaltEval(ctx expr.EvalContext, args []value.Value) (value.Value, bool) { | ||
| // Generate a random number between 1000000000 and 9999999999 | ||
| randomNum := rand.Int63n(9000000000) + 1000000000 |
Contributor
There was a problem hiding this comment.
I think we want to use the crypto rand here? I think we need to fix the imports for the file too...
import "crypto/rand"
...
salt := make([]byte, 10)
if ib, err := rand.Read(salt); err != nil && ib != len(salt) {
return value.EmptyStringValue, false
}
return value.NewStringValue(base64.URLEncoding.EncodeToString(salt)), true
epsniff
reviewed
May 16, 2025
| } | ||
| return value.NewStringValue(string(by)), true | ||
| } | ||
|
|
Contributor
There was a problem hiding this comment.
Im going to talk this one over with the team tomorrow. If the goal here is to have this generate a random salt, that is only set once and never changed. We may need to write this as one of our internal built-ins, so it has context from the entire entity. Otherwise each time the profile is evaluated it's salt will change, which will change it's hashed email address.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a salt function to ql built in expr.